{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "import codecs\n",
    "import csv\n",
    "import time\n",
    "import os\n",
    "import re\n",
    "import gzip\n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "PATH_TO_DATA = 'Data/'\n",
    "PATH_TO_DATA_EN = PATH_TO_DATA+\"enwiki/\"\n",
    "PATH_TO_DATA_UK = PATH_TO_DATA+\"ukwiki/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "ENWIKI_ALI_FNMS = []\n",
    "for file in os.listdir(PATH_TO_DATA_EN):\n",
    "    if re.match(r\"enwiki-20180620-pages-meta-current\\d{2}-p\\d+p\\d+.xml_red.csv.gz\", file):\n",
    "        ENWIKI_ALI_FNMS.append(file)  \n",
    "UKWIKI_ALI_FNMS = []\n",
    "for file in os.listdir(PATH_TO_DATA_UK):\n",
    "    if re.match(r\"ukwiki-20180620-pages-meta-current\\d{2}-p\\d+p\\d+.xml_red.csv.gz\", file):\n",
    "        UKWIKI_ALI_FNMS.append(file)  \n",
    "        \n",
    "UK_ID_NAME = \"ukwiki-20180620-id_name.csv\"\n",
    "EN_ID_NAME = \"enwiki-20180620-id_name.csv\"     "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "def unpack(file_name):\n",
    "    file_name_new = file_name.replace(\".gz\",\"\")\n",
    "    with gzip.open(file_name, 'rb') as f_in, open(file_name_new, 'wb') as f_out:\n",
    "        f_out.writelines(f_in)\n",
    "    return file_name_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "def pack_and_remove(file_name):\n",
    "    file_name_new = file_name+'.gz'\n",
    "    with open(file_name, 'rb') as f_in, gzip.open(file_name_new, 'wb') as f_out:\n",
    "        f_out.writelines(f_in)\n",
    "    os.remove(file_name)\n",
    "    return file_name_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>12</td>\n",
       "      <td>Anarchism</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>25</td>\n",
       "      <td>Autism</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>39</td>\n",
       "      <td>Albedo</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>290</td>\n",
       "      <td>A</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>303</td>\n",
       "      <td>Alabama</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    id      title\n",
       "0   12  Anarchism\n",
       "1   25     Autism\n",
       "2   39     Albedo\n",
       "3  290          A\n",
       "4  303    Alabama"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_en_id_name = pd.read_csv(PATH_TO_DATA_EN+EN_ID_NAME, encoding='ISO-8859-1', \n",
    "                         quotechar=\"'\", escapechar =\"\\\\\")\n",
    "df_en_id_name.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data/enwiki/enwiki-20180620-pages-meta-current01-p10p30303.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (4675, 2)\n",
      "df_id_alias_id_orig size: (4675, 2)\n",
      "df_id_orig_title_alias size: (4675, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current02-p30304p88444.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (16382, 2)\n",
      "df_id_alias_id_orig size: (16382, 2)\n",
      "df_id_orig_title_alias size: (16382, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current03-p88445p200507.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (32776, 2)\n",
      "df_id_alias_id_orig size: (32776, 2)\n",
      "df_id_orig_title_alias size: (32776, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current04-p200511p352689.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (67119, 2)\n",
      "df_id_alias_id_orig size: (67119, 2)\n",
      "df_id_orig_title_alias size: (67119, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current05-p352690p565313.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (121575, 2)\n",
      "df_id_alias_id_orig size: (121575, 2)\n",
      "df_id_orig_title_alias size: (121575, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current06-p565314p892912.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (220427, 2)\n",
      "df_id_alias_id_orig size: (220427, 2)\n",
      "df_id_orig_title_alias size: (220427, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current07-p892914p1268691.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (297702, 2)\n",
      "df_id_alias_id_orig size: (297702, 2)\n",
      "df_id_orig_title_alias size: (297702, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current08-p1268692p1791079.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (410563, 2)\n",
      "df_id_alias_id_orig size: (410563, 2)\n",
      "df_id_orig_title_alias size: (410563, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current09-p1791080p2336422.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (531048, 2)\n",
      "df_id_alias_id_orig size: (531048, 2)\n",
      "df_id_orig_title_alias size: (531048, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current10-p2336425p3046511.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (658472, 2)\n",
      "df_id_alias_id_orig size: (658472, 2)\n",
      "df_id_orig_title_alias size: (658472, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current11-p3046514p3926861.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (807130, 2)\n",
      "df_id_alias_id_orig size: (807130, 2)\n",
      "df_id_orig_title_alias size: (807130, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current12-p3926863p5040436.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (979068, 2)\n",
      "df_id_alias_id_orig size: (979068, 2)\n",
      "df_id_orig_title_alias size: (979068, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current13-p5040438p6197594.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (1162268, 2)\n",
      "df_id_alias_id_orig size: (1162268, 2)\n",
      "df_id_orig_title_alias size: (1162268, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current14-p6197598p7697598.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (1357512, 2)\n",
      "df_id_alias_id_orig size: (1357512, 2)\n",
      "df_id_orig_title_alias size: (1357512, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current14-p7697598p7744799.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (1363069, 2)\n",
      "df_id_alias_id_orig size: (1363069, 2)\n",
      "df_id_orig_title_alias size: (1363069, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current15-p7744803p9244803.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (1558505, 2)\n",
      "df_id_alias_id_orig size: (1558505, 2)\n",
      "df_id_orig_title_alias size: (1558505, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current15-p9244803p9518048.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (1591770, 2)\n",
      "df_id_alias_id_orig size: (1591770, 2)\n",
      "df_id_orig_title_alias size: (1591770, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current16-p11018050p11539266.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (1653139, 2)\n",
      "df_id_alias_id_orig size: (1653139, 2)\n",
      "df_id_orig_title_alias size: (1653139, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current16-p9518050p11018050.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (1808604, 2)\n",
      "df_id_alias_id_orig size: (1808604, 2)\n",
      "df_id_orig_title_alias size: (1808604, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current17-p11539268p13039268.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (2022811, 2)\n",
      "df_id_alias_id_orig size: (2022811, 2)\n",
      "df_id_orig_title_alias size: (2022811, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current17-p13039268p13693071.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (2112630, 2)\n",
      "df_id_alias_id_orig size: (2112630, 2)\n",
      "df_id_orig_title_alias size: (2112630, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current18-p13693074p15193074.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (2342540, 2)\n",
      "df_id_alias_id_orig size: (2342540, 2)\n",
      "df_id_orig_title_alias size: (2342540, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current18-p15193074p16120542.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (2450935, 2)\n",
      "df_id_alias_id_orig size: (2450935, 2)\n",
      "df_id_orig_title_alias size: (2450935, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current19-p16120543p17620543.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (2731204, 2)\n",
      "df_id_alias_id_orig size: (2731204, 2)\n",
      "df_id_orig_title_alias size: (2731204, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current19-p17620543p18754735.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (2871029, 2)\n",
      "df_id_alias_id_orig size: (2871029, 2)\n",
      "df_id_orig_title_alias size: (2871029, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current20-p18754736p20254736.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (3085668, 2)\n",
      "df_id_alias_id_orig size: (3085668, 2)\n",
      "df_id_orig_title_alias size: (3085668, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current20-p20254736p21222156.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (3194662, 2)\n",
      "df_id_alias_id_orig size: (3194662, 2)\n",
      "df_id_orig_title_alias size: (3194662, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current21-p21222158p22722158.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (3397873, 2)\n",
      "df_id_alias_id_orig size: (3397873, 2)\n",
      "df_id_orig_title_alias size: (3397873, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current21-p22722158p23927983.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (3602666, 2)\n",
      "df_id_alias_id_orig size: (3602666, 2)\n",
      "df_id_orig_title_alias size: (3602666, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current22-p23927984p25427984.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (3799098, 2)\n",
      "df_id_alias_id_orig size: (3799098, 2)\n",
      "df_id_orig_title_alias size: (3799098, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current22-p25427984p26823660.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (3980375, 2)\n",
      "df_id_alias_id_orig size: (3980375, 2)\n",
      "df_id_orig_title_alias size: (3980375, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current23-p26823661p28323661.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (4202254, 2)\n",
      "df_id_alias_id_orig size: (4202254, 2)\n",
      "df_id_orig_title_alias size: (4202254, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current23-p28323661p29823661.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (4457948, 2)\n",
      "df_id_alias_id_orig size: (4457948, 2)\n",
      "df_id_orig_title_alias size: (4457948, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current23-p29823661p30503449.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (4578437, 2)\n",
      "df_id_alias_id_orig size: (4578437, 2)\n",
      "df_id_orig_title_alias size: (4578437, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current24-p30503451p32003451.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (4781995, 2)\n",
      "df_id_alias_id_orig size: (4781995, 2)\n",
      "df_id_orig_title_alias size: (4781995, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current24-p32003451p33503451.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (4981258, 2)\n",
      "df_id_alias_id_orig size: (4981258, 2)\n",
      "df_id_orig_title_alias size: (4981258, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current24-p33503451p33952815.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (5037266, 2)\n",
      "df_id_alias_id_orig size: (5037266, 2)\n",
      "df_id_orig_title_alias size: (5037266, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current25-p33952816p35452816.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (5240190, 2)\n",
      "df_id_alias_id_orig size: (5240190, 2)\n",
      "df_id_orig_title_alias size: (5240190, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current25-p35452816p36952816.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (5453726, 2)\n",
      "df_id_alias_id_orig size: (5453726, 2)\n",
      "df_id_orig_title_alias size: (5453726, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current25-p36952816p38067202.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (5613952, 2)\n",
      "df_id_alias_id_orig size: (5613952, 2)\n",
      "df_id_orig_title_alias size: (5613952, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current26-p38067203p39567203.xml_red.csv.gz\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "df_id_alias_title_alias size: (5845704, 2)\n",
      "df_id_alias_id_orig size: (5845704, 2)\n",
      "df_id_orig_title_alias size: (5845704, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current26-p39567203p41067203.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (6043096, 2)\n",
      "df_id_alias_id_orig size: (6043096, 2)\n",
      "df_id_orig_title_alias size: (6043096, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current26-p41067203p42567203.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (6241760, 2)\n",
      "df_id_alias_id_orig size: (6241760, 2)\n",
      "df_id_orig_title_alias size: (6241760, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current26-p42567203p42663461.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (6254473, 2)\n",
      "df_id_alias_id_orig size: (6254473, 2)\n",
      "df_id_orig_title_alias size: (6254473, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p42663462p44163462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (6490208, 2)\n",
      "df_id_alias_id_orig size: (6490208, 2)\n",
      "df_id_orig_title_alias size: (6490208, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p44163462p45663462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (6651982, 2)\n",
      "df_id_alias_id_orig size: (6651982, 2)\n",
      "df_id_orig_title_alias size: (6651982, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p45663462p47163462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (6797347, 2)\n",
      "df_id_alias_id_orig size: (6797347, 2)\n",
      "df_id_orig_title_alias size: (6797347, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p47163462p48663462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (6979558, 2)\n",
      "df_id_alias_id_orig size: (6979558, 2)\n",
      "df_id_orig_title_alias size: (6979558, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p48663462p50163462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (7239259, 2)\n",
      "df_id_alias_id_orig size: (7239259, 2)\n",
      "df_id_orig_title_alias size: (7239259, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p50163462p51663462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (7459167, 2)\n",
      "df_id_alias_id_orig size: (7459167, 2)\n",
      "df_id_orig_title_alias size: (7459167, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p51663462p53163462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (7640010, 2)\n",
      "df_id_alias_id_orig size: (7640010, 2)\n",
      "df_id_orig_title_alias size: (7640010, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p53163462p54663462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (7849969, 2)\n",
      "df_id_alias_id_orig size: (7849969, 2)\n",
      "df_id_orig_title_alias size: (7849969, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p54663462p56163462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (8100407, 2)\n",
      "df_id_alias_id_orig size: (8100407, 2)\n",
      "df_id_orig_title_alias size: (8100407, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p56163462p57663462.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (8302586, 2)\n",
      "df_id_alias_id_orig size: (8302586, 2)\n",
      "df_id_orig_title_alias size: (8302586, 2)\n",
      "Data/enwiki/enwiki-20180620-pages-meta-current27-p57663462p57726175.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (8312092, 2)\n",
      "df_id_alias_id_orig size: (8312092, 2)\n",
      "df_id_orig_title_alias size: (8312092, 2)\n"
     ]
    }
   ],
   "source": [
    "df_id_alias_title_alias = None\n",
    "df_id_alias_id_orig = None\n",
    "df_id_orig_title_alias = None\n",
    "for fn in ENWIKI_ALI_FNMS:\n",
    "    fn = PATH_TO_DATA_EN+fn\n",
    "    print(fn)\n",
    "    fn_new = unpack(fn)\n",
    "    df_aliases = pd.read_csv(fn_new, encoding='ISO-8859-1', quotechar=\"\\\"\")\n",
    "    df_aliases = pd.merge(df_aliases, df_en_id_name, how='left', left_on=['redirect'], right_on=['title'])    \n",
    "    df_aliases = df_aliases[['id_x', 'id_y', 'title_x', 'redirect']]\n",
    "    df_aliases.columns = ['id_alias', 'id_orig', 'title_alias', 'title_orig']    \n",
    "    \n",
    "    df_id_alias_title_alias_tmp = df_aliases[['id_alias', 'title_alias']]\n",
    "    if df_id_alias_title_alias is not None:\n",
    "        df_id_alias_title_alias = df_id_alias_title_alias.append(df_id_alias_title_alias_tmp)        \n",
    "    else:\n",
    "        df_id_alias_title_alias = df_id_alias_title_alias_tmp\n",
    "    print(\"df_id_alias_title_alias size: {}\".format(df_id_alias_title_alias.shape))\n",
    "    \n",
    "    df_id_alias_id_orig_tmp = df_aliases[['id_alias', 'id_orig']]\n",
    "    if df_id_alias_id_orig is not None:\n",
    "        df_id_alias_id_orig = df_id_alias_id_orig.append(df_id_alias_id_orig_tmp)        \n",
    "    else:\n",
    "        df_id_alias_id_orig = df_id_alias_id_orig_tmp\n",
    "    print(\"df_id_alias_id_orig size: {}\".format(df_id_alias_id_orig.shape))\n",
    "    \n",
    "    df_id_orig_title_alias_tmp = df_aliases[['id_orig', 'title_alias']]\n",
    "    if df_id_orig_title_alias is not None:\n",
    "        df_id_orig_title_alias = df_id_orig_title_alias.append(df_id_orig_title_alias_tmp)        \n",
    "    else:\n",
    "        df_id_orig_title_alias = df_id_orig_title_alias_tmp\n",
    "    print(\"df_id_orig_title_alias size: {}\".format(df_id_orig_title_alias.shape))\n",
    "    os.remove(fn_new)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_alias</th>\n",
       "      <th>title_alias</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10</td>\n",
       "      <td>AccessibleComputing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13</td>\n",
       "      <td>AfghanistanHistory</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>14</td>\n",
       "      <td>AfghanistanGeography</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15</td>\n",
       "      <td>AfghanistanPeople</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>18</td>\n",
       "      <td>AfghanistanCommunications</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_alias                title_alias\n",
       "0        10        AccessibleComputing\n",
       "1        13         AfghanistanHistory\n",
       "2        14       AfghanistanGeography\n",
       "3        15          AfghanistanPeople\n",
       "4        18  AfghanistanCommunications"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_alias_title_alias.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_alias_title_alias.to_csv(PATH_TO_DATA_EN+'enwiki-20180620-id_alias_title_alias.csv', index = False, encoding='ISO-8859-1', quotechar=\"'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_alias_id_orig[['id_orig']] = df_id_alias_id_orig[['id_orig']].fillna(-1).astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_alias</th>\n",
       "      <th>id_orig</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10</td>\n",
       "      <td>411964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13</td>\n",
       "      <td>13813</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>14</td>\n",
       "      <td>12681</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15</td>\n",
       "      <td>66468</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>18</td>\n",
       "      <td>6684</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_alias  id_orig\n",
       "0        10   411964\n",
       "1        13    13813\n",
       "2        14    12681\n",
       "3        15    66468\n",
       "4        18     6684"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_alias_id_orig.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_alias_id_orig.to_csv(PATH_TO_DATA_EN+'enwiki-20180620-id_alias_id_orig.csv', index = False, encoding='ISO-8859-1', quotechar=\"'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_orig_title_alias[['id_orig']] = df_id_orig_title_alias[['id_orig']].fillna(-1).astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8312090, 2)"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_orig_title_alias.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_orig_title_alias = df_id_orig_title_alias.drop_duplicates()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8312090, 2)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_orig_title_alias.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_orig</th>\n",
       "      <th>title_alias</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>411964</td>\n",
       "      <td>AccessibleComputing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13813</td>\n",
       "      <td>AfghanistanHistory</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>12681</td>\n",
       "      <td>AfghanistanGeography</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>66468</td>\n",
       "      <td>AfghanistanPeople</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6684</td>\n",
       "      <td>AfghanistanCommunications</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_orig                title_alias\n",
       "0   411964        AccessibleComputing\n",
       "1    13813         AfghanistanHistory\n",
       "2    12681       AfghanistanGeography\n",
       "3    66468          AfghanistanPeople\n",
       "4     6684  AfghanistanCommunications"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_orig_title_alias.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_orig_title_alias.to_csv(PATH_TO_DATA_EN+'enwiki-20180620-id_orig_title_alias.csv', index = False, encoding='ISO-8859-1', quotechar=\"'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>Головна сторінка</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13</td>\n",
       "      <td>Географія</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>584</td>\n",
       "      <td>Атом</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>585</td>\n",
       "      <td>Мільярд</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>586</td>\n",
       "      <td>Ядро</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    id             title\n",
       "0    3  Головна сторінка\n",
       "1   13         Географія\n",
       "2  584              Атом\n",
       "3  585           Мільярд\n",
       "4  586              Ядро"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_uk_id_name = pd.read_csv(PATH_TO_DATA_UK+UK_ID_NAME, encoding='UTF-8', quotechar=\"\\\"\")\n",
    "df_uk_id_name.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data/ukwiki/ukwiki-20180620-pages-meta-current01-p1p110726.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (110724, 2)\n",
      "df_id_alias_id_orig size: (110724, 2)\n",
      "df_id_orig_title_alias size: (110724, 2)\n",
      "Data/ukwiki/ukwiki-20180620-pages-meta-current02-p110727p221452.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (221448, 2)\n",
      "df_id_alias_id_orig size: (221448, 2)\n",
      "df_id_orig_title_alias size: (221448, 2)\n",
      "Data/ukwiki/ukwiki-20180620-pages-meta-current03-p221453p332177.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (332172, 2)\n",
      "df_id_alias_id_orig size: (332172, 2)\n",
      "df_id_orig_title_alias size: (332172, 2)\n",
      "Data/ukwiki/ukwiki-20180620-pages-meta-current04-p332178p442902.xml_red.csv.gz\n",
      "df_id_alias_title_alias size: (442895, 2)\n",
      "df_id_alias_id_orig size: (442895, 2)\n",
      "df_id_orig_title_alias size: (442895, 2)\n"
     ]
    }
   ],
   "source": [
    "df_id_alias_title_alias = None\n",
    "df_id_alias_id_orig = None\n",
    "df_id_orig_title_alias = None\n",
    "for fn in UKWIKI_ALI_FNMS:\n",
    "    fn = PATH_TO_DATA_UK+fn\n",
    "    print(fn)\n",
    "    fn_new = unpack(fn)\n",
    "    df_aliases = pd.read_csv(fn_new, encoding='UTF-8', quotechar=\"\\\"\")\n",
    "    df_aliases = pd.merge(df_aliases, df_uk_id_name, how='left', left_on=['redirect'], right_on=['title'])    \n",
    "    df_aliases = df_aliases[['id_x', 'id_y', 'title_x', 'redirect']]\n",
    "    df_aliases.columns = ['id_alias', 'id_orig', 'title_alias', 'title_orig']    \n",
    "    \n",
    "    df_id_alias_title_alias_tmp = df_aliases[['id_alias', 'title_alias']]\n",
    "    if df_id_alias_title_alias is not None:\n",
    "        df_id_alias_title_alias = df_id_alias_title_alias.append(df_id_alias_title_alias_tmp)        \n",
    "    else:\n",
    "        df_id_alias_title_alias = df_id_alias_title_alias_tmp\n",
    "    print(\"df_id_alias_title_alias size: {}\".format(df_id_alias_title_alias.shape))\n",
    "    \n",
    "    df_id_alias_id_orig_tmp = df_aliases[['id_alias', 'id_orig']]\n",
    "    if df_id_alias_id_orig is not None:\n",
    "        df_id_alias_id_orig = df_id_alias_id_orig.append(df_id_alias_id_orig_tmp)        \n",
    "    else:\n",
    "        df_id_alias_id_orig = df_id_alias_id_orig_tmp\n",
    "    print(\"df_id_alias_id_orig size: {}\".format(df_id_alias_id_orig.shape))\n",
    "    \n",
    "    df_id_orig_title_alias_tmp = df_aliases[['id_orig', 'title_alias']]\n",
    "    if df_id_orig_title_alias is not None:\n",
    "        df_id_orig_title_alias = df_id_orig_title_alias.append(df_id_orig_title_alias_tmp)        \n",
    "    else:\n",
    "        df_id_orig_title_alias = df_id_orig_title_alias_tmp\n",
    "    print(\"df_id_orig_title_alias size: {}\".format(df_id_orig_title_alias.shape))\n",
    "    os.remove(fn_new)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_alias</th>\n",
       "      <th>title_alias</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>Esperanto</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6</td>\n",
       "      <td>Wikipedia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>HomePage</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>647</td>\n",
       "      <td>Капустянко Микола</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>693</td>\n",
       "      <td>Володимир Винниченко</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_alias           title_alias\n",
       "0         2             Esperanto\n",
       "1         6             Wikipedia\n",
       "2         9              HomePage\n",
       "3       647     Капустянко Микола\n",
       "4       693  Володимир Винниченко"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_alias_title_alias.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_alias_title_alias.to_csv(PATH_TO_DATA_UK+'ukwiki-20180620-id_alias_title_alias.csv', index = False, encoding='UTF-8', quotechar=\"\\\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_alias_id_orig[['id_orig']] = df_id_alias_id_orig[['id_orig']].fillna(-1).astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_alias</th>\n",
       "      <th>id_orig</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>610</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6</td>\n",
       "      <td>9701</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>647</td>\n",
       "      <td>61817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>693</td>\n",
       "      <td>6083</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_alias  id_orig\n",
       "0         2      610\n",
       "1         6     9701\n",
       "2         9        3\n",
       "3       647    61817\n",
       "4       693     6083"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_alias_id_orig.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_alias_id_orig.to_csv(PATH_TO_DATA_UK+'ukwiki-20180620-id_alias_id_orig.csv', index = False, encoding='UTF-8', quotechar=\"\\\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_orig_title_alias[['id_orig']] = df_id_orig_title_alias[['id_orig']].fillna(-1).astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(442895, 2)"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_orig_title_alias.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(442895, 2)"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_orig_title_alias = df_id_orig_title_alias.drop_duplicates()\n",
    "df_id_orig_title_alias.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_orig</th>\n",
       "      <th>title_alias</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>610</td>\n",
       "      <td>Esperanto</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9701</td>\n",
       "      <td>Wikipedia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>HomePage</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>61817</td>\n",
       "      <td>Капустянко Микола</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6083</td>\n",
       "      <td>Володимир Винниченко</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_orig           title_alias\n",
       "0      610             Esperanto\n",
       "1     9701             Wikipedia\n",
       "2        3              HomePage\n",
       "3    61817     Капустянко Микола\n",
       "4     6083  Володимир Винниченко"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_id_orig_title_alias.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_id_orig_title_alias.to_csv(PATH_TO_DATA_UK+'ukwiki-20180620-id_orig_title_alias.csv', index = False, encoding='UTF-8', quotechar=\"\\\"\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
